package com.demo.transaction.service;

import com.demo.transaction.annotation.ChildTransaction;
import com.demo.transaction.domain.User;
import com.demo.transaction.mapper.TestOneMapper;
import com.demo.transaction.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @Author: lkz
 * @Title: TestService
 * @Description: TODO
 * @Date: 2023/7/14 15:47
 */
@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;


    @Transactional(rollbackFor = Exception.class)
    @Async("threadPoolTaskExecutor")
    @ChildTransaction
    public void useTest(Thread thread){
        User user = new User();
        user.setUsername("张五个");
        user.setId(11);
        userMapper.insert(user);
    }



}
